package com.mallcloud.mall.app.controller;

import com.mallcloud.mall.app.service.AppPointsCardService;
import com.mallcloud.mall.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@Api(tags = "app-用户积分余额信息")
@RestController
@AllArgsConstructor
@RequestMapping("/app/userPointsBalance")
public class AppUserPointsBalanceController {
    private final AppPointsCardService appPointsCardService;

    @ApiOperation(value = "查询积分余额")
    @GetMapping("/pointsBalance")
    public R<Long> pointsBalance(@RequestParam String cardNo) {
        return R.ok(appPointsCardService.getById(cardNo).getPoints());
    }

    @ApiOperation(value = "查询电子余额")
    @GetMapping("/valueBalance")
    public R<BigDecimal> valueBalance(@RequestParam String cardNo) {
        return R.ok(appPointsCardService.getById(cardNo).getBalance());
    }
}
